#ifndef CONFIG_H
#define CONFIG_H

#include <string>
#include <vector>
#include "nlohmann/json.hpp"

struct AppInfo {
    std::wstring name;
    std::vector<std::wstring> productNameList;
    std::vector<std::wstring> fileNamePatternList;
    std::wstring tag;
};

struct BlockType {
    bool enable;
    std::wstring title;
    std::wstring content;
};

struct Policy {
    std::vector<std::wstring> pathTrustList;
    std::vector<AppInfo> appBlockList;
    std::vector<AppInfo> appTrustList;
    std::vector<std::wstring> entryBlockList;
    std::map<std::wstring, BlockType> blockTypes;
};

struct Config {
    std::string logLevel;
    std::string logPath;
    Policy policy;
};

void from_json(const nlohmann::json &j, AppInfo &info);

void to_json(nlohmann::json &j, const AppInfo &info);

void from_json(const nlohmann::json &j, Policy &info);

void to_json(nlohmann::json &j, const Policy &policy);

void from_json(const nlohmann::json &j, BlockType &blockType);

void to_json(nlohmann::json &j, const BlockType &blockType);

void from_json(const nlohmann::json &j, Config &info);

void to_json(nlohmann::json &j, const Config &info);

class FilterConfig {
public:
    explicit FilterConfig(const std::string &configPath);

    ~FilterConfig() = default;

    std::string GetLogPath() const;

    std::string GetLogLevel() const;

    std::vector<std::wstring> GetTrustedPathList();

    std::vector<std::wstring> GetTrustedProductNameList() const;

    std::vector<std::wstring> GetTrustedFileNamePatternList() const;

    std::vector<std::wstring> GetUnTrustedProcessNameList() const;

    std::vector<AppInfo> GetBlockAppList() const;

    std::map<std::wstring, BlockType> GetBlockTypes() const;

private:
    void Init();

    std::string configPath;
    Config config;
};

#endif
